import request from '@/config/axios'
import type { Dayjs } from 'dayjs';

/** 路由信息 */
export interface Route {
          routeId: number; // ID
          createdAt: string | Dayjs; // 创建时间
          updatedAt: string | Dayjs; // 更新时间
          deviceId?: number; // 设备ID
          portId?: number; // 端口ID
          contextName: string; // SNMP 上下文名称
          inetCidrRouteIfIndex?: number; // 接口索引
          inetCidrRouteType?: number; // 路由类型（如 1	=直连, 2	=静态, 3	=动态）
          inetCidrRouteProto?: number; // 路由协议（如 1	=静态, 2	=RIP, 3	=OSPF, 4	=BGP）
          inetCidrRouteNextHopAS?: number; // 下一跳 AS 号
          inetCidrRouteMetric1?: number; // 路由度量值
          inetCidrRouteDestType?: string; // 目的地址类型
          inetCidrRouteDest?: string; // 目的网络地址
          inetCidrRouteNextHopType?: string; // 下一跳地址类型
          inetCidrRouteNextHop?: string; // 下一跳 IP 地址
          inetCidrRoutePolicy?: string; // 策略路由标识
          inetCidrRoutePfxLen?: number; // 目的网络前缀长度
  }

// 路由 API
export const RouteApi = {
  // 查询路由分页
  getRoutePage: async (params: any) => {
    return await request.get({ url: `/business/route/page`, params })
  },

  // 查询路由详情
  getRoute: async (id: number) => {
    return await request.get({ url: `/business/route/get?id=` + id })
  },

  // 新增路由
  createRoute: async (data: Route) => {
    return await request.post({ url: `/business/route/create`, data })
  },

  // 修改路由
  updateRoute: async (data: Route) => {
    return await request.put({ url: `/business/route/update`, data })
  },

  // 删除路由
  deleteRoute: async (id: number) => {
    return await request.delete({ url: `/business/route/delete?id=` + id })
  },

  /** 批量删除路由 */
  deleteRouteList: async (ids: number[]) => {
    return await request.delete({ url: `/business/route/delete-list?ids=${ids.join(',')}` })
  },

  // 导出路由 Excel
  exportRoute: async (params) => {
    return await request.download({ url: `/business/route/export-excel`, params })
  },
}